let localstorage = {
  get: (key) => {
    return new Promise((resolve, reject) => {
      let string = window.localStorage.getItem(key);
      try {
        let data = JSON.parse(string);
        resolve(data);
      } catch (err) {
        reject(err);
      }
    });

  },
  set: (key, data) => {
    return new Promise((resolve, reject) => {
      let string = JSON.stringify(data);
      window.localStorage.setItem(key, string);
      resolve({ err: 0 });
    });
  },
  remove: (key) => {
    return new Promise((resolve, reject) => {
      window.localStorage.removeItem(key);
      resolve({ err: 0 });
    });
  }
}

export default localstorage;